package parser;

import antlr.RecognitionException;
import antlr.Token;

class NotExpr extends Expr {
    
    Expr expr;
    
    NotExpr(Expr expr) {
        this.expr = expr;
    }

    void delete(ByteStream out) throws RecognitionException {
        throw new RecognitionException("Cannot delete rvalue");
    }
 
    void write(ByteStream out) throws RecognitionException {
        expr.write(out);
        out.write(Opcodes.NOT);
    }
    
    Patch branch(boolean onTrue, ByteStream out) throws RecognitionException {
        return expr.branch(!onTrue, out);   
    }   
    
    void writeLHS(ByteStream out) throws RecognitionException {
        throw new RecognitionException("Cannot assign to not operator");
    }
    
}
